#!/bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop
SQOOP_HOME=/usr/bin/sqoop
if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM customer where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_customer \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM customer_appeal where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_customer_appeal \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM customer_clue where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_customer_clue \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM customer_relationship where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_customer_relationship \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM employee where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_employee \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS dt
FROM itcast_clazz where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_itcast_clazz \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM itcast_school where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_itcast_school \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM itcast_subject where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_itcast_subject \
-m 1
wait

sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/scrm \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'SELECT
  *, "2022-10-10" AS start_time
FROM scrm_department where 1=1 and $CONDITIONS' \
--hcatalog-database zx_ods \
--hcatalog-table z_scrm_department \
-m 1
wait